import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/hire/pages/hire_rent_info/view.dart';
import 'package:honeypotflutter/public/public_date.dart';
import 'package:honeypotflutter/public/public_total.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import '../models/hire_rent_model.dart';

class HireRentItem extends StatelessWidget {
  final HireRentModel itemModel;
  const HireRentItem({super.key, required this.itemModel});

  @override
  Widget build(BuildContext context) {
    return MGCard(
      margin: EdgeInsets.all(12),
      children: [
        Container(
          margin: EdgeInsets.only(bottom: 10),
          width: double.infinity,
          child: Text(
            itemModel.deviceName ?? "",
            style: TextStyle(
              color: MGColors.text1Color,
              fontSize: MGFont.textFont1,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
        Flex(direction: Axis.horizontal, children: [
          Expanded(
              flex: 1,
              child: Container(
                decoration: BoxDecoration(
                  color: MGColors.backColor,
                  borderRadius: BorderRadius.circular(4),
                ),
                padding: EdgeInsets.only(top: 10, bottom: 10),
                child: Column(
                  children: [
                    Image.asset(
                      (itemModel.contractSmallNo != null && itemModel.contractSmallNo! > 0) ? MGImage.image("public_small") : MGImage.image("public_small_hui"),
                      width: 25,
                    ),
                    SizedBox(height: 5),
                    Text(
                      itemModel.contractSmallNo.toString(),
                      style: TextStyle(
                        color: MGColors.text1Color,
                        fontSize: MGFont.textFont2,
                      ),
                    )
                  ],
                ),
              )),
          SizedBox(width: 16),
          Expanded(
              flex: 1,
              child: Container(
                decoration: BoxDecoration(
                  color: MGColors.backColor,
                  borderRadius: BorderRadius.circular(4),
                ),
                padding: EdgeInsets.only(top: 10, bottom: 10),
                child: Column(
                  children: [
                    Image.asset(
                      (itemModel.contractMediumNo != null && itemModel.contractMediumNo! > 0) ? MGImage.image("public_middle") : MGImage.image("public_middle_hui"),
                      width: 25,
                    ),
                    SizedBox(height: 5),
                    Text(
                      itemModel.contractMediumNo.toString(),
                      style: TextStyle(
                        color: MGColors.text1Color,
                        fontSize: MGFont.textFont2,
                      ),
                    )
                  ],
                ),
              )),
          SizedBox(width: 16),
          Expanded(
              flex: 1,
              child: Container(
                decoration: BoxDecoration(
                  color: MGColors.backColor,
                  borderRadius: BorderRadius.circular(4),
                ),
                padding: EdgeInsets.only(top: 10, bottom: 10),
                child: Column(
                  children: [
                    Image.asset(
                      (itemModel.contractLargeNo != null && itemModel.contractLargeNo! > 0) ? MGImage.image("public_big") : MGImage.image("public_big_hui"),
                      width: 25,
                    ),
                    SizedBox(height: 5),
                    Text(
                      itemModel.contractLargeNo.toString(),
                      style: TextStyle(
                        color: MGColors.text1Color,
                        fontSize: MGFont.textFont2,
                      ),
                    )
                  ],
                ),
              ))
        ]),
        Container(
          margin: EdgeInsets.only(top: 10),
          width: double.infinity,
          child: Text(
            "${HLDate.hl_formatDate(itemModel.startTime)}- ${HLDate.hl_formatDate(itemModel.endTime)}",
            style: TextStyle(
              color: MGColors.text3Color,
              fontSize: MGFont.textFont3,
            ),
            textAlign: TextAlign.end,
          ),
        )
      ],
      action: () {
        if (itemModel.isActive == false) {
          HLTotal.total("订单已失效");
          return;
        }
        Get.to(HireRentInfoPage(), arguments: itemModel);
      },
    );
  }
}
